import {
	callFunc
} from "../../request.js"

// 创建预约订单
export function genSubscribeOrder({
	orderType,
	showLoading = true,
	scriptId,
	maleCount,
	femaleCount,
	startTime,
	endTime,
	storeId,
	roomId,
	useBalance = false,
	allowGetOn = true, //当当前人数大于等于最低人数后，是否允许继续加人
	motorcadeId, // 车队id
	couponId, //优惠券id
	// buyCardId, //会员卡/折扣卡id
	shareManId,
	currentOrderId
}) {
	return callFunc({
		showLoading,
		funcName: 'uni-admin',
		data: {
			action: 'order/genSubscribeScriptOrder',
			data: {
				orderType,
				scriptId,
				maleCount,
				femaleCount,
				startTime,
				endTime,
				storeId,
				roomId,
				useBalance,
				allowGetOn, //当当前人数大于等于最低人数后，是否允许继续加人
				motorcadeId, // 车队id
				couponId, //优惠券id
				// buyCardId, //会员卡/折扣卡id
				shareManId,
				currentOrderId
			}
		}
	})
}

// 更新未支付的预约订单信息
export function uptateUnpaidOrder({
	showLoading = true,
	orderType,
	couponId, //优惠券id
	startTime,
	endTime,
	scriptId,
	maleCount,
	femaleCount,
	roomId,
	useBalance = false,
	// buyCardId, //会员卡/折扣卡id
	shareManId,
	orderId
}) {
	return callFunc({
		showLoading,
		funcName: 'uni-admin',
		data: {
			action: 'order/uptateUnpaidOrder',
			data: {
				orderType,
				couponId, //优惠券id
				startTime,
				endTime,
				scriptId,
				maleCount,
				femaleCount,
				roomId,
				useBalance,
				// buyCardId, //会员卡/折扣卡id
				shareManId,
				orderId
			}
		}
	})
}

export function getReceiptNames({
	showLoading = true,
	ticketId,
	giftId,
	orderId
}) {
	return callFunc({
		showLoading,
		funcName: "uni-admin",
		data: {
			action: "order/getReceiptNames",
			data: {
				ticketId,
				giftId,
				orderId
			}
		}
	})
}

export function getReceiptList({
	showLoading = true,
	ticketId,
	giftId,
	name,
	status,
	orderId,
	pageNum = 1,
	pageSize = 10
}) {
	return callFunc({
		showLoading,
		funcName: "uni-admin",
		data: {
			action: "order/getReceiptList",
			data: {
				ticketId,
				giftId,
				name,
				status,
				orderId,
				pageNum,
				pageSize
			}
		}
	})
}

//创建商品订单
export function genGoodsOrder({
	skuId,
	count,
	useBalance,
	shareManId,
	showLoading = true
}) {
	return callFunc({
		showLoading,
		funcName: 'uni-admin',
		data: {
			action: 'order/genGoodsOrder',
			data: {
				skuId,
				count,
				useBalance,
				shareManId
			}
		}
	})
}
//创建开通会员订单
export function genOpenVipOrder({
	vipCardId,
	showLoading = true
}) {
	return callFunc({
		showLoading,
		funcName: 'uni-admin',
		data: {
			action: 'order/genOpenVipOrder',
			data: {
				vipCardId
			}
		}
	})
}

//创建礼包订单
export function getQrcode({
	packageId,
	showLoading = true
}) {
	return callFunc({
		showLoading,
		funcName: 'uni-admin',
		data: {
			action: 'order/getPackageQrcode',
			data: {
				packageId
			}
		}
	})
}

//创建礼包订单
export function updatePakcageState({
	orderId,
	user,
	showLoading = true
}) {
	return callFunc({
		showLoading,
		funcName: 'uni-admin',
		data: {
			action: 'order/updatePakcageState',
			data: {
				orderId,
				user
			}
		}
	})
}

//创建礼包订单
export function genPackageOrder({
	packageId,
	shareManId,
	showLoading = true
}) {
	return callFunc({
		showLoading,
		funcName: 'uni-admin',
		data: {
			action: 'order/genPackageOrder',
			data: {
				packageId,
				shareManId
			}
		}
	})
}

//创建充值订单
export function genRechargeOrder({
	amount,
	showLoading = true
}) {
	return callFunc({
		showLoading,
		funcName: 'uni-admin',
		data: {
			action: 'order/genRechargeOrder',
			data: {
				amount
			}
		}
	})
}

//创建租借订单
export function genRentOrder({
	goodsId,
	count,
	showLoading = true
}) {
	return callFunc({
		showLoading,
		funcName: 'uni-admin',
		data: {
			action: 'order/genRentOrder',
			data: {
				goodsId,
				count
			}
		}
	})
}

//生成支付信息
export function genPayInfo({
	orderId,
	provider,
	showLoading = true
}) {
	return callFunc({
		showLoading,
		funcName: 'uni-admin',
		data: {
			action: 'order/genPayInfo',
			data: {
				orderId,
				provider
			}
		}
	})
}
//查询支付状态
export function queryPayStatus(orderId, options) {
	return callFunc({
		...options,
		funcName: "queryPayStatus",
		data: {
			orderId: orderId,
			token: uni.getStorageSync('token')
		}
	})
}

//获取待开发票的订单
export function getMyNeedInvoiceOrders({
	showLoading = true,
	orderType,
	pageNum = 1,
	pageSize = 10
}) {
	return callFunc({
		showLoading,
		funcName: "uni-admin",
		data: {
			action: 'member-self/getMyNeedInvoiceOrders',
			data: {
				orderType,
				pageNum,
				pageSize
			}
		}
	})
}

//获取我的订单
export function getMyOrders({
	showLoading = true,
	status,
	type,
	pageNum = 1,
	pageSize = 10
}) {
	return callFunc({
		showLoading,
		funcName: "uni-admin",
		data: {
			action: 'member-self/getMyOrders',
			data: {
				type,
				status,
				pageNum,
				pageSize
			}
		}
	})
}

//获取我的订单
export function getMyBuyOrders({
	showLoading = true,
	orderType,
	status,
	pageNum = 1,
	pageSize = 10,
	createStartTime,
	createEndTime,
	applyInvoice
}) {
	return callFunc({
		showLoading,
		funcName: "uni-admin",
		data: {
			action: 'order/getMyOrders',
			data: {
				orderType,
				status,
				pageNum,
				pageSize,
				createStartTime,
				createEndTime,
				applyInvoice
			}
		}
	})
}

//获取订单详情
export function getOrderDetail({
	id,
	userLocation,
	showLoading
}) {
	return callFunc({
		showLoading,
		funcName: "uni-admin",
		data: {
			action: 'order/getOrderDetail',
			data: {
				id,
				userLocation,
			}
		}
	})
}
//获取退款信息列表中退款数量的动态变化
export function calcRefundFee({
	orderId,
	count,
	showLoading
}) {
	return callFunc({
		showLoading,
		funcName: "uni-admin",
		data: {
			action: 'order/calcRefundFee',
			data: {
				orderId,
				count,
			}
		}
	})
}
//获取退款订单详情
export function getOrderRefundDetail({
	orderId,
	userLocation,
	showLoading
}) {
	return callFunc({
		showLoading,
		funcName: "uni-admin",
		data: {
			action: 'order/getOrderRefundDetail',
			data: {
				orderId,
				userLocation
			}
		}
	})
}

export function getRefundApplyDetail({
	applyId,
	showLoading
}) {
	return callFunc({
		showLoading,
		funcName: "uni-admin",
		data: {
			action: 'order/getRefundApplyDetail',
			data: {
				applyId
			}
		}
	})
}

//申请退款
export function applyRefund({
	orderId,
	reason,
	count,
	photos,
	showLoading
}) {
	return callFunc({
		showLoading,
		funcName: "uni-admin",
		data: {
			action: 'order/applyRefund',
			data: {
				orderId,
				reason,
				count,
				photos
			}
		}
	})
}

//取消订单
export function cancelOrder({
	orderId,
	showLoading = true
}) {
	return callFunc({
		showLoading,
		funcName: "uni-admin",
		data: {
			action: 'order/cancelOrder',
			data: {
				orderId
			}
		}
	})
}

export function createEvaluation({
	orderId,
	score,
	description,
	open,
	photos,
	option
}) {
	return callFunc({
		...option,
		funcName: "uni-admin",
		data: {
			action: 'order/createEvaluation',
			data: {
				orderId,
				score,
				description,
				photos,
				open
			}
		}
	})
}

export function exitMotorcade({
	motorcadeId,
	orderId,
	showLoading = true
}) {
	return callFunc({
		showLoading,
		funcName: "uni-admin",
		data: {
			action: 'order/exitMotorcade',
			data: {
				motorcadeId,
				orderId
			}
		}
	})
}

export function genTearoomOrder({
	showLoading = true,
	orderType,
	startTime,
	endTime,
	storeId,
	roomId,
	useBalance = false,
	couponId, //优惠券id
	// buyCardId, //会员卡/折扣卡id
	shareManId,
	tearoomOrderId // 当前茶室订单id
}) {
	return callFunc({
		showLoading,
		funcName: 'uni-admin',
		data: {
			action: 'order/genTearoomOrder',
			data: {
				orderType,
				startTime,
				endTime,
				storeId,
				roomId,
				useBalance,
				couponId, //优惠券id
				// buyCardId, //会员卡/折扣卡id
				shareManId,
				tearoomOrderId // 当前茶室订单id
			}
		}
	})
}